package com.linkage.educloud.ah.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.linkage.educloud.ah.bean.ClazzGroup;
import com.linkage.educloud.ah.view.fragment.ContactClazzFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * <desc>
 * Created by The Moss on 2018/11/8.
 */

public class MyFragmentAdapter extends FragmentPagerAdapter {
    List<ClazzGroup> groups;

    public MyFragmentAdapter(FragmentManager fm) {
        super(fm);
        this.groups = new ArrayList<>();
    }
    public void setDatas(List<ClazzGroup> groups){
        this.groups.clear();
        this.groups.addAll(groups);
        notifyDataSetChanged();
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return groups.get(position).school_name
                + groups.get(position).group_name;
    }

    @Override
    public int getCount() {
        return groups.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        // TODO Auto-generated method stub
        return super.instantiateItem(container, position);
    }

    @Override
    public Fragment getItem(int position) {
        return ContactClazzFragment.newInstance(groups.get(position).classid);
    }
}
